package com.oa.lms.apps.business.limit.impl;

import java.util.List;

import com.oa.lms.apps.business.limit.ILimitInfoService;
import com.oa.lms.apps.business.limit.IPostLimitService;
import com.oa.lms.apps.dao.limit.ILimitInfoDao;
import com.oa.lms.apps.entity.limit.LimitInfoValue;
import com.oa.lms.apps.entity.limit.PostLimitValue;

public class LimitInfoServiceImpl implements ILimitInfoService{
	
	private ILimitInfoDao infoDao;
	private IPostLimitService postLimitService;
	
	// Service method
	
	@Override
	public LimitInfoValue queryByLimitId(Integer limitId) throws Exception {
		return infoDao.queryByLimitId(limitId);
	}
	
	@Override
	public List<LimitInfoValue> queryByLimitIds(String limitIds) throws Exception {
		if(limitIds != null){ 
			return infoDao.queryByLimitIds(limitIds);
		}
		return null;
	}
	
	@Override
	public List<LimitInfoValue> queryByParentId(Integer parentId, Integer postId)
			throws Exception {
		PostLimitValue postLimit = postLimitService.queryByPostId(postId);
		if(postLimit != null)
			return infoDao.queryByParentId(parentId, postLimit.getLimitIds());
		return null;
	}
	
	// Service property accessors
	
	public ILimitInfoDao getInfoDao() {
		return infoDao;
	}

	public void setInfoDao(ILimitInfoDao infoDao) {
		this.infoDao = infoDao;
	}

	public void setPostLimitService(IPostLimitService postLimitService) {
		this.postLimitService = postLimitService;
	}

	public IPostLimitService getPostLimitService() {
		return postLimitService;
	}
	
}
